package com.behome.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.behome.common.annotation.DataScope;
import com.behome.system.domain.TMediaType;
import com.behome.system.domain.TTerminalInfo;
import com.behome.system.mapper.TTerminalInfoMapper;
import com.behome.system.service.ITerminalInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 部门管理 服务实现
 *
 * @author behome
 */
@Service
public class TerminalInfoServiceImpl implements ITerminalInfoService {

    @Resource
    private TTerminalInfoMapper tTerminalInfoMapper;

    @Override
    @DataScope(regionAlias = "re")
    public List<TTerminalInfo> selectTeminalInfoList(TTerminalInfo tTerminalInfo) {
        return tTerminalInfoMapper.selectTeminalInfoList(tTerminalInfo);
    }

    @Override
    public int insertUser(TTerminalInfo tTerminalInfo) {
        tTerminalInfo.setStatus("03");
        tTerminalInfo.setCreateTime(new Date());
        tTerminalInfo.setUpdateTime(new Date());
        tTerminalInfoMapper.insert(tTerminalInfo);
        return 0;
    }

    @Override
    public int updateTerminal(TTerminalInfo tTerminalInfo) {
        UpdateWrapper<TTerminalInfo> updateWrapper = new UpdateWrapper<>();
        tTerminalInfo.setUpdateTime(new Date());
        updateWrapper.eq("physical_address",tTerminalInfo.getPhysicalAddress());
        return tTerminalInfoMapper.update(tTerminalInfo,updateWrapper);
    }


}
